home *** CD-ROM | disk | FTP | other *** search
- Path: news.clark.net!not-for-mail
- From: gusty@clark.net (Harlan Messinger)
- Newsgroups: comp.lang.c++
- Subject: Re: Argument from commandline???
- Date: 1 Feb 1996 22:20:57 GMT
- Organization: Clark Internet Services, Inc., Ellicott City, MD USA
- Message-ID: <4erec9$f88@clarknet.clark.net>
- References: <4eou36$p6g@prometheus.algonet.se>
- NNTP-Posting-Host: explorer.clark.net
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
-
- Nylund Patrik (bifrost@algonet.se) wrote:
- : How do I include argument from the commandline to the main function in
- : a c++ program?
- :
-
-
- The proper full definition of the function "main" is
-
- int main(int argc, char *argv[]) {
- ...
- }
-
- The arguments argc and argv are available for use in your program. argc
- is set to the number of words on your command line (words being strings
- of non-whitespace characters separated by whitespace characters). For
- example, if your command line has no arguments, argc will be 1, because
- only the name of the program itself is on the command line.
-
- argv[i] is an array of character pointers, defined for 0 <= i < argc, that
- point to copies of your command line arguments. The pointer argv[0] points
- to the name of the program as you invoked it, if your system makes that
- available. The command line arguments are then at argv[1], ..., argv[argc
- - 1].
-
-